package com.lzy.product.service.impl;

import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.OrderProductImageMapperExt;
import com.lzy.product.dtos.OrderProductImageDto;
import com.lzy.product.entity.OrderProductImage;
import com.lzy.product.service.OrderProductImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by WIN7 on 2017/12/5.
 */
@Service
public class OrderProductImageServiceImpl implements OrderProductImageService {

    @Autowired
    OrderProductImageMapperExt orderProductImageMapperExt;

    @Override
    public Long insert(OrderProductImageDto dto) {
        OrderProductImage orderProductImage = DozerUtils.map(dto, OrderProductImage.class);
        return orderProductImageMapperExt.insertSelective(orderProductImage) > 0 ? orderProductImage.getId() : 0L;
    }

    @Override
    public Boolean update(OrderProductImageDto dto) {
        return orderProductImageMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto, OrderProductImage.class)) > 0;
    }

    @Override
    public Boolean delete(Long id) {
        return orderProductImageMapperExt.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public OrderProductImageDto findById(Long id) {
        return DozerUtils.map(orderProductImageMapperExt.selectByPrimaryKey(id), OrderProductImageDto.class);
    }

    @Override
    public List<OrderProductImageDto> query(OrderProductImageDto dto) {
        return orderProductImageMapperExt.selectList(dto);
    }

    @Override
    public List<OrderProductImageDto> findByOrderId(Long orderId) {
        return orderProductImageMapperExt.findByOrderId(orderId);
    }
}
